package org.imis.action;

import java.text.SimpleDateFormat;
import java.util.Date;

import org.imis.domain.*;
import org.imis.service.NewsManage;
public class SaveAddAction {
	private NewsManage newsManage;
    private String title;
    private String content;
    private String table;
	public String getTitle() {
		return title;
	}
	public void setTitle(String title) {
		this.title = title;
	}
	public String getContent() {
		return content;
	}
	public void setContent(String content) {
		this.content = content;
	}
	public String getTable() {
		return table;
	}
	public void setTable(String table) {
		this.table = table;
	}

	public String execute()
	{
		 Date date=new Date();  
		 SimpleDateFormat formatter=new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");  
		 String time=formatter.format(date);  
		 System.out.println(time);
		 if(table.equals("News"))
		 {
		News news=new News();
		news.setTitle(title);
		news.setContent(content);
		news.setTime(time);
		newsManage.saveNews(news);
		 }
		 else if(table.equals("Notice"))
		 {
			 Notice news=new Notice();
				news.setTitle(title);
				news.setContent(content);
				news.setTime(time);
				newsManage.saveNews(news);
			 
		 }
		 else if(table.equals("Forum"))
		 {
			 Forum news=new Forum();
				news.setTitle(title);
				news.setContent(content);
				news.setTime(time);
				newsManage.saveNews(news);
			 
		 }
		 else if(table.equals("Information"))
		 {
			 Information news=new Information();
				news.setTitle(title);
				news.setContent(content);
				news.setTime(time);
				newsManage.saveNews(news);
			 
		 }
		 else if(table.equals("PConsult"))
		 {
			 PConsult news=new PConsult();
				news.setTitle(title);
				news.setContent(content);
				news.setTime(time);
				newsManage.saveNews(news);
			 
		 }
		 else if(table.equals("RConsult"))
		 {
			 RConsult news=new RConsult();
				news.setTitle(title);
				news.setContent(content);
				news.setTime(time);
				newsManage.saveNews(news);
			 
		 }
		 else if(table.equals("StudentShip"))
		 {
			 StudentShip news=new StudentShip();
				news.setTitle(title);
				news.setContent(content);
				news.setTime(time);
				newsManage.saveNews(news);
			 
		 }
		 else if(table.equals("StuGroup"))
		 {
			 StuGroup news=new StuGroup();
				news.setTitle(title);
				news.setContent(content);
				news.setTime(time);
				newsManage.saveNews(news);
			 
		 }
		 else if(table.equals("StuHonor"))
		 {
			 StuHonor news=new StuHonor();
				news.setTitle(title);
				news.setContent(content);
				news.setTime(time);
				newsManage.saveNews(news);
			 
		 }
		 
		
	    return "success";
	}
	public NewsManage getNewsManage() {
		return newsManage;
	}
	public void setNewsManage(NewsManage newsManage) {
		this.newsManage = newsManage;
	}



	
}
